package app.fugema.shop.main.center.adapter;

import com.base.common.utils.DensityUtil;
import com.base.common.utils.UIUtils;
import com.base.common.view.adapter.ada.BaseRVAdapter;
import com.base.common.view.adapter.connector.BaseItemMultiType;
import com.base.common.view.adapter.connector.BaseViewHolder;

import android.view.View;

import androidx.lifecycle.LifecycleOwner;
import app.fugema.shop.R;
import app.fugema.shop.databinding.ItemGitfGoodsViewBinding;
import app.fugema.shop.main.center.model.GiftOrderBean;
import app.fugema.shop.main.center.vm.JiFenOrderVM;

public class GiftGoodsItemMultiType extends BaseItemMultiType<GiftOrderBean.ItemsBean, ItemGitfGoodsViewBinding>
{

    private JiFenOrderVM orderListVM;

    public GiftGoodsItemMultiType(LifecycleOwner lifecycleOwner, JiFenOrderVM orderListVM)
    {
        super(lifecycleOwner);
        this.orderListVM = orderListVM;
    }


    @Override
    public int getLayoutId()
    {
        return R.layout.item_gitf_goods_view;
    }


    @Override
    public void onBindViewHolder(ItemGitfGoodsViewBinding binding, int position, BaseViewHolder viewHolder,GiftOrderBean.ItemsBean bean)
    {
        super.onBindViewHolder(binding, position, viewHolder, bean);
        if (viewHolder.getAdapter() != null)
        {
            int firstPos = viewHolder.getAdapter().getFirstPosition(BaseItemMultiType.TYPE_CHILD, 0);
            if (firstPos == position)
            {
                //binding.clItemView.getDelegate().setCornerRadius_TR(DensityUtil.getDimens(R.dimen.dp_10));
                //binding.clItemView.getDelegate().setCornerRadius_TL(DensityUtil.getDimens(R.dimen.dp_10));
            }
            else
            {
                //binding.clItemView.getDelegate().setCornerRadius_TR(0);
                //binding.clItemView.getDelegate().setCornerRadius_TL(0);
            }
        }

        /*
        StringBuffer specSb = new StringBuffer();
        if(UIUtils.isNotEmpty( bean.getSize() ))
        {
            specSb.append( bean.getSizeAlias() ).append(":").append(bean.getSize()).append(" ");
        }
        if(UIUtils.isNotEmpty( bean.getColor() ))
        {
            specSb.append( bean.getColorAlias() ).append(":").append(bean.getColor()).append(" ");
        }
        if(UIUtils.isNotEmpty( bean.getVersion() ))
        {
            specSb.append( bean.getVersionAlias() ).append(":").append(bean.getVersion());
        }
        binding.tvSpecification.setText( specSb.toString() );
        */
        //订单的当前状态  1:待付款 2:待发货 3:待收货 4:待评价 5:成功 6:失败
        //if (bean.getStatus() == 2 || bean.getStatus() == 3 || bean.getStatus() == 4 || bean.getStatus() == 5)
        {
            //binding.rtvRefund.setVisibility(View.VISIBLE);
            //binding.rtvEvaluate.setVisibility(View.VISIBLE);
        }
        //1为待审核,2为未发货，3为不同意,4已发货退款处理中，5退款成功，6退款失败
        /*
        switch (bean.getRefundType()) {
            case 1:
            case 2:
            case 4:
                binding.rtvRefund.setText("退款中");
                break;
            case 3:
            case 6:
                binding.rtvRefund.setText("退款失败");
                break;
            case 5:
                binding.rtvRefund.setText("退款成功");
                break;
            default:
                binding.rtvRefund.setText("退款");
                break;
        }
        */
    }

    @Override
    public void onItemClick(View view, BaseRVAdapter adapter, int onclickType, int position,GiftOrderBean.ItemsBean bean)
    {
        super.onItemClick(view, adapter, onclickType, position, bean);
        switch (view.getId())
        {
            case R.id.givGoodsImage:
                //GoodsDetailActivity.start(view.getContext(), bean.getProductId());
                break;

            //case R.id.rtvEvaluate:
                //OrderAfterSaleCreateActivity.start(view.getContext(), bean.getOrderNumber(), bean);
                //OrderAfterSaleDetailActivity.start(view.getContext(), bean.getRefundSn());
                // 评价
                //EvaluateAddActivity.start(view.getContext(), bean);
             //break;
        }

    }
}
